package com.housekeeping.housekeeping.user.service.impl;

import com.housekeeping.housekeeping.serviceItem.utils.CodeUtils;
import com.housekeeping.housekeeping.user.dao.UserDao;
import com.housekeeping.housekeeping.user.dao.impl.UserDaoImpl;
import com.housekeeping.housekeeping.user.entity.Account;
import com.housekeeping.housekeeping.user.entity.AccountVo;
import com.housekeeping.housekeeping.user.service.UserService;

import java.sql.SQLException;

public class UserServiceImpl implements UserService {
    private UserDao dao=new UserDaoImpl();
    @Override
    public int register(Account account) throws SQLException {
        //生成盐
        String sale= CodeUtils.generateSalt();
        account.setPassword(CodeUtils.md5Hex(account.getPassword(),sale));
        return dao.register(account,sale);
    }

    @Override
    public int accountExist(String account) throws SQLException {
        return dao.accountExist(account);
    }

    @Override
    public AccountVo login(String account, String password) throws SQLException {
        return dao.login(account,password);
    }
}
